package ChangableParams;

import java.util.Arrays;
import java.util.List;

public class TestParam {
public static void main(String[] args) {
	sum(1,2,3,4,5);
	
	Integer arr[] = {1,2,3,4,5};
	sum(arr);
	
	List list = Arrays.asList(1,2,3);
	System.out.println(list);
	
	Integer arr2[] ={1,2,3,4,5};
	list = Arrays.asList(arr2);//5个元素
	System.out.println(list);
	
	//注意问题
	int a[] = {1,2,3};
	list = Arrays.asList(a);//1个元素
	
}
public static void sum(Integer ... args){
	
	//可变参数在编程时当成数组即可
	int sum =0;
	for (int arg : args) {
		sum+=arg;
	}
	System.out.println(sum);
}


}
